package com.example.demo.enums;

import java.util.HashMap;
import java.util.Map;

public enum CollectNeedSameTimeEnum {

    //--------------需要同时获取的点---------------

    ZJ_ARPM("ZJ#arpm", "主机转速", "ZJ"),
    ZJ_LOAD("ZJ#load", "主机负荷", "ZJ"),

    FJ_ARPM("FJ#arpm", "辅机转速", "FJ"),

    WI1A001("WI1a001", "风速", null),
    WI1A002("WI1a002", "风向", null),

    SH_ARPM("SH#aRPM", "主轴转速", "SH"),
    SH_APOW("SH#aPOW", "主轴功率", "SH"),

    GP1A001("GP1a001", "经纬度", null),

    ZJ_JTOM("ZJ#jtom", "主机燃油流量", "ZJ"),
    ZJ_HTOM("ZJ#htom", "主机回油流量", "ZJ"),
    FJ_JTOM("FJ#jtom", "辅机燃油流量", "FJ"),
    FJ_HTOM("FJ#htom", "辅机回油流量", "FJ"),
    GL1JTOM("GL1jtom", "锅炉燃油流量", null),
    GL1HTOM("GL1htom", "锅炉回油流量", null),

    ZJ_YXSJ("ZJ#yxsj", "主机运行时间", "ZJ"),
    FJ_YXSJ("FJ#yxsj", "辅机运行时间", "FJ"),
    GL1YXSJ("GL1yxsj", "锅炉运行时间", null),

    ZJ_SJGL("ZJ#sjgl", "主机实际功率", "ZJ"),
    ZJ_HYLV("ZJ#hylv", "主机比油耗", "ZJ");


    private String key;

    private String value;

    private String deviceCode;

    CollectNeedSameTimeEnum(String key, String value, String deviceCode) {
        this.key = key;
        this.value = value;
        this.deviceCode = deviceCode;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public String getDeviceCode() {
        return deviceCode;
    }

    public static Boolean hasKey(String key) {
        Boolean flag = false;

        for (CollectNeedSameTimeEnum e : values()) {
            if (e.getKey().equals(key)) {
                flag = true;
            }
        }

        return flag;
    }

    public static Map<String, String> getKeysAndDeviceCode() {
        Map<String, String> map = new HashMap<>();

        for (CollectNeedSameTimeEnum e : values()) {
            map.put(e.getKey(), e.getDeviceCode());
        }
        return map;
    }

    public static String getValueByKey(String key) {
        for (CollectNeedSameTimeEnum e : values()) {
            if (e.getKey().equals(key)) return e.getValue();
        }
        return null;
    }
}
